#include "thread.hpp"
#include "threadPool.hpp"
#include "lockGuard.hpp"
#include "Task.hpp"
#include "log.hpp"
#include <ctime>
#include <cstdio>
#include <unistd.h>
int main()
{
    // logMessage(1,"%s %d %c %p","你好",333,'c',0x666);
    srand((unsigned int)time(nullptr) ^ 113095);
    threadPool<Task>* tp = new threadPool<Task>();
    tp->run();
    //tp->join();
    while(true)
    {
        // 生产的过程，制作任务的时候要花时间
        int x = rand() % 1000 + 1;
        usleep(5432);
        int y = rand() % 424;
        Task t(x,y,[](int x,int y)->int{return x + y;});
        // std::cout << "制作任务完成：" << x << "+" << y << "=?" << std::endl;
        logMessage(DEBUG,"制作任务完成,%d + %d = ?",x,y);
        // 推送任务到线程池中
        tp->pushTask(t);
        sleep(1);
    }
    return 0;
}